package com.harmontronics.hanma.paas.paas.domain.organization.repository.mapper;

import com.harmontronics.hanma.paas.paas.domain.organization.entity.OrgTree;
import com.harmontronics.hanma.paas.paas.domain.organization.entity.OrgUserExport;
import com.harmontronics.hanma.paas.paas.domain.organization.repository.po.HmOrgPO;
import com.harmontronics.hanma.paas.paas.domain.organization.repository.po.HmUserOrgPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户和组织映射表
 * 
 * @author paas-generator
 * @email paas-generator@harmontronics.com
 * @date 2021-04-01 14:45:14
 */
@Mapper
public interface HmUserOrgMapper extends BaseMapper<HmUserOrgPO> {

    List<OrgTree> selectOrgWithUserId(@Param("userId") Long userId);

    @Select(" select ho.id, \"name\", parent_id, parent_ids from hm_org ho\n"
            + "        left join hm_user_org huo on huo.org_id = ho.id\n"
            + "        where huo.user_id = #{userId}")
    List<HmOrgPO> selectOrgByUserId(Long userId);

    List<OrgUserExport> selectExportUserWithOrgId(@Param("orgIdList") List<Long> orgIdList,
            @Param("orgId") long orgId, @Param("name") String name,
            @Param("username") String username, @Param("mobile") String mobile,
            @Param("status") Integer status, @Param("email") String email);
}
